package util;

import java.util.HashMap;
import java.util.Map;

public final class Util
{
	private static Map<String,Class<?>> classInstance=new HashMap<String, Class<?>>();
	
	public static Object loadObject(String name)
	{
		return loadObject(name,null);
	}
	public static Object loadObject(String name,ClassLoader loader)
	{
		try
		{
			Class c=classInstance.get(name);
			if(c==null)
			{
				c=(loader!=null)?loader.loadClass(name):Class.forName(name);
				classInstance.put(name, c);
			}
			return c.newInstance();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		return null;
	}
	
}
